package com.lolongmaps.test;

import java.util.ArrayList;
import com.lolongmaps.model.Restaurant;;


public class Sorter {

	private ArrayList<Restaurant> restaurants;
	
	public Sorter(ArrayList<Restaurant> restaurants) {
		
		this.restaurants = restaurants;
		
	}
	
	public void sort() {
		
		for(int x=0; x<restaurants.size(); x++) {
			
			for(int y=0; y<restaurants.size(); y++) {
				
				Restaurant temp = restaurants.get(x);
				
				if(restaurants.get(x).getDistance() < restaurants.get(y).getDistance()) {
					
					restaurants.set(x, restaurants.get(y));
					restaurants.set(y, temp);
					
				}			
				
			}
			
		} 
		
	}
	
	public ArrayList<Restaurant> getRestaurants() {
		
		return restaurants;
		
	}
	
}
